package com.talent.service.iot.mqtt.model.variable;

import java.util.Objects;

/**
 * @ClassName：TlMqttVariableHead
 * @Author: hszhou
 * @Date: 2024/11/25 11:13
 * @Description: 发布消息的可变头
 */
public class TlMqttPublishVariableHead {


    private String topic;
    private Integer messageId;


    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public Integer getMessageId() {
        return messageId;
    }

    public void setMessageId(Integer messageId) {
        this.messageId = messageId;
    }

    public TlMqttPublishVariableHead(String topic, Integer messageId) {
        this.topic = topic;
        this.messageId = messageId;
    }

    public TlMqttPublishVariableHead(String topic) {
        this.topic = topic;
    }

    public static TlMqttPublishVariableHead of(String topic, int messageId){
        return new TlMqttPublishVariableHead(topic,messageId);
    }

    public static TlMqttPublishVariableHead of(String topic){
        return new TlMqttPublishVariableHead(topic);
    }

    @Override
    public String toString() {
        return "TlMqttPublishVariableHead{" +
                "topic='" + topic + '\'' +
                ", messageId=" + messageId +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TlMqttPublishVariableHead that = (TlMqttPublishVariableHead) o;
        return Objects.equals(topic, that.topic) && Objects.equals(messageId, that.messageId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(topic, messageId);
    }
}
